package com.xunlai.infra.permission.manager.authority.web;

import cn.hutool.cache.impl.WeakCache;
import org.springframework.stereotype.Service;

/**
 * @author liang
 * @date 9/4/23 6:17 PM
 */
@Service("smsCaptchaStorage")
public class SimpleSmsCaptchaStorage implements CaptchaStorage{

    private final WeakCache<String,String> cache = new WeakCache<>(1*60*1000L);

    @Override
    public void save(String sessionId, String code) {
        cache.put(sessionId,code);
    }

    @Override
    public String get(String sessionId) {
        return cache.get(sessionId);
    }

    @Override
    public void remove(String sessionId) {
        cache.remove(sessionId);
    }
}
